this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(n,e,t,i,a){"use strict";var o=function(n){babelHelpers.inherits(e,n);function e(n){var i;babelHelpers.classCallCheck(this,e);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(e).call(this,n));i.setEventNamespace("BX.Landing.UI.Field.TextField");i.subscribeFromOptions(a.fetchEventsFromOptions(n));i.bind=i.options.bind;i.changeTagButton=i.options.changeTagButton;i.onInputHandler=t.Type.isFunction(i.options.onInput)?i.options.onInput:function(){};i.onValueChangeHandler=t.Type.isFunction(i.options.onValueChange)?i.options.onValueChange:function(){};i.textOnly=t.Type.isBoolean(i.options.textOnly)?i.options.textOnly:false;i.content=i.textOnly?t.Text.encode(i.content):i.content;i.input.innerHTML=i.content;i.onInputClick=i.onInputClick.bind(babelHelpers.assertThisInitialized(i));i.onInputMousedown=i.onInputMousedown.bind(babelHelpers.assertThisInitialized(i));i.onDocumentMouseup=i.onDocumentMouseup.bind(babelHelpers.assertThisInitialized(i));i.onInputInput=i.onInputInput.bind(babelHelpers.assertThisInitialized(i));i.onDocumentClick=i.onDocumentClick.bind(babelHelpers.assertThisInitialized(i));i.onDocumentKeydown=i.onDocumentKeydown.bind(babelHelpers.assertThisInitialized(i));i.onInputKeydown=i.onInputKeydown.bind(babelHelpers.assertThisInitialized(i));t.Event.bind(i.input,"click",i.onInputClick);t.Event.bind(i.input,"mousedown",i.onInputMousedown);t.Event.bind(i.input,"input",i.onInputInput);t.Event.bind(i.input,"keydown",i.onInputKeydown);t.Event.bind(document,"click",i.onDocumentClick);t.Event.bind(document,"keydown",i.onDocumentKeydown);t.Event.bind(document,"mouseup",i.onDocumentMouseup);return i}babelHelpers.createClass(e,[{key:"onInputInput",value:function n(){this.onInputHandler(this.input.innerText);this.onValueChangeHandler(this);var e=new i.BaseEvent({data:{value:this.getValue()},compatData:[this.getValue()]});this.emit("onChange",e)}},{key:"onDocumentKeydown",value:function n(e){if(e.keyCode===27){if(this.isEditable()){if(this===BX.Landing.UI.Field.BaseField.currentField){BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}this.disableEdit()}}}},{key:"onInputKeydown",value:function n(e){if(e.keyCode===13){if(this.isTextOnly()){e.preventDefault()}}}},{key:"enableTextOnly",value:function n(){this.textOnly=true;this.input.innerHTML="".concat(this.input.innerText).trim()}},{key:"disableTextOnly",value:function n(){this.textOnly=false}},{key:"isTextOnly",value:function n(){return this.textOnly}},{key:"isContentEditable",value:function n(){return this.contentEditable!==false}},{key:"onDocumentClick",value:function n(){if(this.isEditable()&&!this.fromInput){if(this===BX.Landing.UI.Field.BaseField.currentField){BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}this.disableEdit()}this.fromInput=false}},{key:"onDocumentMouseup",value:function n(){var e=this;setTimeout((function(){e.fromInput=false}),10)}},{key:"onInputClick",value:function n(e){e.preventDefault();e.stopPropagation();this.fromInput=false}},{key:"onInputMousedown",value:function n(e){this.enableEdit();BX.Landing.UI.Tool.ColorPicker.hideAll();requestAnimationFrame((function(){if(e.target.nodeName==="A"){var n=document.createRange();n.selectNode(e.target);window.getSelection().removeAllRanges();window.getSelection().addRange(n)}}));this.fromInput=true;e.stopPropagation()}},{key:"enableEdit",value:function n(){if(!this.isEditable()){if(this!==BX.Landing.UI.Field.BaseField.currentField&&BX.Landing.UI.Field.BaseField.currentField!==null){BX.Landing.UI.Field.BaseField.currentField.disableEdit()}BX.Landing.UI.Field.BaseField.currentField=this;if(!this.isTextOnly()){if(this.changeTagButton){this.changeTagButton.onChangeHandler=this.onChangeTag.bind(this)}BX.Landing.UI.Panel.EditorPanel.getInstance().show(this.layout,null,this.changeTagButton?[this.changeTagButton]:null);this.input.contentEditable=true}else{BX.Landing.UI.Panel.EditorPanel.getInstance().hide();this.input.contentEditable=true}if(!this.isContentEditable()){this.input.contentEditable=false}}}},{key:"onChangeTag",value:function n(e){this.tag=e}},{key:"disableEdit",value:function n(){this.input.contentEditable=false}},{key:"isEditable",value:function n(){return this.input.isContentEditable}},{key:"reset",value:function n(){this.setValue("")}},{key:"adjustTags",value:function n(e){if(e.lastChild&&e.lastChild.nodeName==="BR"){t.Dom.remove(e.lastChild);this.adjustTags(e)}return e}},{key:"getValue",value:function n(){if(this.textOnly){return this.input.innerText}return this.adjustTags(t.Runtime.clone(this.input)).innerHTML.replace(/&nbsp;/g,"")}}]);return e}(e.BaseField);n.TextField=o;n.Text=o})(this.BX.Landing.UI.Field=this.BX.Landing.UI.Field||{},BX.Landing.UI.Field,BX,BX.Event,BX.Landing.UI.Component);
//# sourceMappingURL=textfield.bundle.map.js